<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<%@ include file="/app/include.jsp"%>
		<script type="text/javascript">
			// 创建问卷
			function createSurvey(){
				var fromUrl = "${pageContext.request.contextPath}/app/survey/design/model/create-one-survey.jsp";
				var toUrl = "${pageContext.request.contextPath}/model/createModelSurvey.do";
				var title = "创建问卷";
				function callback(data){ // 进行跳转
					self.location = "${pageContext.request.contextPath}/model/designSurvey.do?surveyuuid="+data;
				}
				Tool.showCallbackDialog(fromUrl,toUrl,title,600,130,callback);
			}
			
			// 设计问卷
			function designSurvey(surveyuuid){
				self.location = "${pageContext.request.contextPath}/model/designSurvey.do?surveyuuid="+surveyuuid;
			}
			
			// 更改问卷状态
			function updateSurveyStatus(surveyuuid,status){
				var params = {};
				params.surveyuuid = surveyuuid;
				params.status = status;
				$.ajax({
					url: ctx + "/model/updateSurveyStatus.do",
					data: params,
					dataType: "text",
					type: "post",
					async:false,
					cache:false,
					success: function(data){
						alert(data);
						Page.queryPage();
					}
				});
			}
		</script>
	</head>
	<body>
		<div class="right_content">
			<ul class="breadcrumb">
				<li>
					问卷管理
					<span>/</span>
				</li>
				<li class="active">
					问卷设计
				</li>
			</ul>
			<div class="list-wrap">
				<form id="queryForm" name="queryForm" action="${pageContext.request.contextPath}/model/loadDesignList.do">
					<div class="pull">
						<div class="pull-left">
							问卷标题&nbsp;<input id="name" name="name" type="text" style="width: 240px;" value="${name}"/>
						</div>
						<div class="pull-right">
							<input type="button" class="btn btn-primary" value="查询" onclick="Page.queryPage();"/>
							<input type="button" class="btn btn-primary" value="重置" onclick="Page.clearForm();"/>
							<input type="button" class="btn btn-primary" value="新增问卷" onclick="createSurvey();"/>
						</div>
					</div>
				</form>
				<div class="table-wrap">
					<table border="0" cellpadding="0" cellspacing="0" class="list">
						<thead>
							<tr>
								<th style="width: 8%">序号</th>
								<th>问卷标题</th>
								<th style="width: 10%">问卷状态</th>
								<th style="width: 10%">样本数量</th>
								<th style="width: 12%">创建人</th>
								<th style="width: 20%">创建日期</th>
								<th style="width: 20%">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="survey" items="${page.list}" varStatus="status">
							<tr>
								<td>${page.pageSize * (page.pageNo - 1) + status.index + 1 }</td>
								<td><a href="#">${survey.name }</a></td>
								<td><open:out value="${survey.status }" valueset="[wenjuanzt]" /></td>
								<td></td>
								<td>${survey.creatorname }</td>
								<td>${open:format(survey.createtime,"yyyy-MM-dd hh:mm:ss")}</td>
								<td>
									<a href="javascript:void(0);" onclick="designSurvey('${survey.surveyuuid }');">设计</a>&nbsp;
									<c:if test="${survey.status == 0}">
										<a href="javascript:void(0);" onclick="updateSurveyStatus('${survey.surveyuuid }',1);">发布</a>&nbsp;&nbsp;
									</c:if>
									<c:if test="${survey.status == 1}">
										<a href="javascript:void(0);" onclick="updateSurveyStatus('${survey.surveyuuid }',0);">取消</a>&nbsp;
									</c:if>
									<a href="#">删除</a>
								</td>
							</tr>
							</c:forEach>
							<c:if test="${fn:length(page.list) == 0}">
								<tr>
									<td colspan=7 align="center"><font color=red><strong>没有可用的问卷模板！</strong></font></td>
								</tr>
							</c:if>
						</tbody>
					</table>
				</div>

				<!--分页开始-->
				${page.operate }
				<!--/分页结束-->
			</div>
		</div>
	</body>
</html>